#前台登录
def DBshopLogin(dr,userName,password):
    dr.find_element_by_link_text("登录").click()
    dr.find_element_by_id("user_name").send_keys(userName)
    dr.find_element_by_id("user_password").send_keys(password)
    dr.find_element_by_xpath('//button').click()
#修改密码
def DBshopChangePassword(dr,password,newPassword):
    dr.find_element_by_link_text("用户中心").click()
    dr.find_element_by_link_text("账户信息").click()
    dr.find_element_by_link_text("密码修改").click()
    dr.find_element_by_id("old_user_password").send_keys(password)
    dr.find_element_by_id("user_password").send_keys(newPassword)
    dr.find_element_by_id("user_password_con").send_keys(newPassword)
    dr.find_element_by_xpath('//button[text()="保存修改"]').click()
#注册
def DBshopRegister(dr,userName,password,email):
    dr.find_element_by_link_text("注册").click()
    dr.find_element_by_id("user_name").send_keys(userName)
    dr.find_element_by_id("user_password").send_keys(password)
    dr.find_element_by_id("user_com_passwd").send_keys(password)
    dr.find_element_by_id("user_email").send_keys(email)
    dr.find_element_by_id("agreement").click()
    dr.find_element_by_xpath('//button[@type="submit"]').click()
    dr.find_element_by_link_text("退出").click()

# ---------------------------------------------------------------------#

#后台登录
def DBshopLoginAdmin(dr):
    dr.find_element_by_id("user_name").send_keys("admin")
    dr.find_element_by_id("user_passwd").send_keys("123456")
    dr.find_element_by_xpath('//button[text()="后台登录"]').click()
# 后台3级菜单处理
def DBshopEnterMenu3(dr,menu1,menu2,menu3):
    from public.action import moveToElement
    dr.find_element_by_link_text(menu1).click()
    moveToElement(dr,dr.find_element_by_link_text(menu2))
    dr.find_element_by_link_text(menu3).click()
# 后台2级菜单处理
def DBshopEnterMenu2(dr,menu1,menu2):
    dr.find_element_by_link_text(menu1).click()
    dr.find_element_by_link_text(menu2).click()
#后台订单搜索
def DBshopSearchOrderID(dr,orderID):
    dr.find_element_by_name("order_sn").send_keys(orderID)
    dr.find_element_by_xpath('//button').click()